#include "fieldinfo.h"
#include "sqlite3.h"

CXFieldInfo::CXFieldInfo(void)
{
    m_strName.clear();
    m_strTypeName.clear();
    m_strDefault.clear();
    m_nType = 0;
    m_nDecimals = 0;
    m_nLength = 0;
    m_nFlag = 0;
}

CXFieldInfo::~CXFieldInfo(void)
{
}

LPCSTR CXFieldInfo::GetName()
{
    return m_strName.c_str();
}

UINT CXFieldInfo::GetFlag()
{
    return m_nFlag;
}

LPCSTR CXFieldInfo::GetTypeName()
{
    return m_strTypeName.c_str();
}

int CXFieldInfo::GetType()
{
    return m_nType;
}

ULONG CXFieldInfo::GetLength()
{
    return m_nLength;
}

LPCSTR CXFieldInfo::GetDefault()
{
    return m_strDefault.c_str();
}

UINT CXFieldInfo::GetDecimals()
{
    return m_nDecimals;
}

HRESULT CXFieldInfo::SetFlag(UINT nFlag)
{
    m_nFlag = nFlag;
    return S_OK;
}

HRESULT CXFieldInfo::SetName(LPCSTR lspzName)
{
    rc_error(lspzName != NULL, E_FAIL);
    m_strName = lspzName;
    return S_OK;
}

HRESULT CXFieldInfo::SetType(int nType)
{
    m_nType = nType;
    return S_OK;
}

HRESULT CXFieldInfo::SetTypeName(LPCSTR lpszType)
{
    rc_error(lpszType != NULL, E_FAIL);
    m_strTypeName = lpszType;
    return S_OK;
}

HRESULT CXFieldInfo::SetLength(unsigned long nLength)
{
    m_nLength = nLength;
    return S_OK;
}

HRESULT CXFieldInfo::SetDefault(LPCSTR lpszValue)
{
    rc_error(lpszValue != NULL, E_FAIL);
    m_strDefault = lpszValue;
    return S_OK;
}

HRESULT CXFieldInfo::SetDecimals(unsigned int nDecimals)
{
    m_nDecimals = nDecimals;
    return S_OK;
}

HRESULT CXFieldInfo::CreateInstance(IFieldInfo** ppFieldInfo)
{
    CXFieldInfo* p = ALLOC_NEW CXFieldInfo();
    rc_error(p != NULL, E_FAIL);
    return p->QueryInterface(IID_IFieldInfo, (void**)ppFieldInfo);
}
